package com.copa.l2341;

import java.util.Arrays;

/**
 * @author copa
 * @createDate 2023-02-16 09:24
 * @function 排序法
 */
public class Test1 {

    public int[] numberOfPairs(int[] nums) {
        int[] result = new int[2];
        nums = Arrays.stream(nums).sorted().toArray();
        int n = nums.length;
        for (int i = 0; i < n - 1; i++) {
            if (nums[i] == nums[i + 1]) {
                result[0]++;
                i++;
            }
        }
        result[1] = n - result[0] * 2;
        return result;
    }

    public static void main(String[] args) {
        int[] nums = {1,3,2,1,3,2,2};
        int[] result = new Test1().numberOfPairs(nums);
        System.out.println(result[0] + ":" + result[1]);
    }
}
